package com.controller;

import com.alibaba.fastjson2.JSONObject;
import com.pojo.K3bm;
import com.server.GetK3bmServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
public class GetK3bmController {
    private final GetK3bmServer getK3bmServer;

    @Autowired
    public GetK3bmController(GetK3bmServer getK3bmServer) {
        this.getK3bmServer = getK3bmServer;
    }

    @RequestMapping("/get/K3bm")
    @ResponseBody
    public List<K3bm> getK3bm(@RequestBody JSONObject jsonObject) {
        Integer page = jsonObject.getInteger("page");
        Integer limit = jsonObject.getInteger("limit");
        String k3bm = jsonObject.getString("k3bm");
        String k3mc = jsonObject.getString("k3mc");
        k3bm = (k3bm != null) ? k3bm : "";
        k3mc = (k3mc != null) ? k3mc : "";
        List<K3bm> k3bm1 = getK3bmServer.getK3bm(k3bm, k3mc, limit, page);
        return k3bm1;
    }
}
